package com.kaigejava.sortingalgorithm.insertionsorting;

/**
 * 两个数组合并
 */
public class ListAppendTest {
    public static void main(String[] args) {
        int [] a = {1,3,4};
        int [] b = {2,5,6};
        Node node = new Node(a.length+b.length);
        for (int i = 0; i < a.length; i++) {
            node.add(a[i]);
        }
        for (int i = 0; i < b.length; i++) {
            node.add(b[i]);
        }
        //显示合并后的
        node.showAll();
    }
}



class Node {
    /**
     * 队列的最大值
     */
    private int maxSize;

    /**
     * 队列头
     */
    private int front;

    /**
     * 对列尾部
     */
    private  int rear;

    /**
     * 存放数据的容器
     */
    private int [] arr;

    /**
     * 初始化队列
     * @param maxSize
     */
    public Node(int maxSize){
        this.maxSize = maxSize;
        this.arr = new int[maxSize];
        this.front = -1;
        this.rear = -1;
    }

    public void add(int value){
        rear ++;
        arr[rear] = value;
    }

    public void showAll(){
        for (int i = 0; i < arr.length; i++) {
            System.out.printf("arr[%d] = %d \n ",i,arr[i]);
        }
    }
}
